//
//  NSDictionary+BCPDictionary.m
//  BCP
//
//  Created by zhangke on 16/4/23.
//  Copyright © 2016年 525happy. All rights reserved.
//

#import "NSDictionary+BCPDictionary.h"

@implementation NSDictionary (BCPDictionary)

- (NSString *)dictionaryCompareKeys{
    NSArray *array1 = [self allKeys];
    NSArray *array2 = [array1 sortedArrayUsingSelector:@selector(compare:options:)];
    
    NSString *resultString;
    for (int i=0; i<[array2 count]; i++) {
        if (i==0) {
            resultString = [NSString stringWithFormat:@"%@=%@",array2[0],[self objectForKey:array2[0]]];
        }else {
            resultString = [NSString stringWithFormat:@"%@&%@=%@",resultString,array2[i],[self objectForKey:array2[i]]];
        }
    }
    
    return resultString;
}

@end
